home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 118_01.zip / DATE.BDS < prev    next >
Text File  |  1993-06-03  |  2KB  |  93 lines

  1. /* Time and date routines for Software Tools
  2.  * source:  date.bds
  3.  * version: August 22, 1981
  4.  */
  5.  
  6. #include tools.h
  7.  
  8. /*    fmtdat - format date and time information into date
  9.  *               form is reserved for a format selector.
  10.  *             time is a scratch buffer
  11.  */
  12.  
  13. fmtdat (date, time, now, form)
  14. char *date, *time, *now;
  15. int form;
  16. {
  17.  
  18.     /* copy now to date.  do not copy newline */
  19.     while (*now != NEWLINE && *now != EOS) {
  20.         *date++ = *now++;
  21.     }
  22.     *date = EOS;
  23.  
  24.     /* comment out ----- format date and time
  25.     date [0] = now [1] / 10 + '0';
  26.     date [1] = now [1] % 10 + '0';
  27.     date [2] = '/';
  28.     date [3] = now [2] / 10 + '0';
  29.     date [4] = now [2] % 10 + '0';
  30.     date [5] = '/';
  31.     date [6] = now [0] % 100 / 10 + '0';
  32.     date [7] = now [0] % 10 + '0';
  33.     date [8] = EOS;
  34.  
  35.     time [0] = now [3] / 10 + '0';
  36.     time [1] = now [3] % 10 + '0';
  37.     time [2] = '/';
  38.     time [3] = now [4] / 10 + '0';
  39.     time [4] = now [4] % 10 + '0';
  40.     time [5] = ':';
  41.     time [6] = now [5] / 10 + '0';
  42.     time [7] = now [5] % 10 + '0';
  43.     time [8] = EOS;
  44.     ----- end comment out */
  45. }
  46.  
  47. /*  getnow - return pointer to current time and date */
  48.  
  49. char * getnow ()
  50. {
  51.     if (sys_date [0] == EOS) {
  52.         putlin("\nEnter date:  \n", SYS_TERM);
  53.         getlin(sys_date, SYS_TERM);
  54.         if (sys_date [0] == EOS) {
  55.             sys_date [0] == ' ';
  56.             sys_date [1] == EOS;
  57.         }
  58.     }
  59.     return(sys_date);
  60.  
  61.  
  62.     /* comment out ----- set now [], date []
  63.     now [0] = 1981;    /*  the year */
  64.     now [1] = 1;    /*  the month */
  65.     now [2] = 1;    /*  the day */
  66.     now [3] = 23;        /*  the hour (24-hour clock) */
  67.     now [4] = 59;        /*  the minute of the hour */
  68.     now [5] = 59;        /*  the second of the minute */
  69.     now [6] = 999;        /*  the millisecond */
  70.     ----- end comment out */
  71.  
  72. }
  73.  
  74.  
  75. /*  wkday - get day-of-week corresponding to month,day,year */
  76.  
  77. int wkday (month, day, year)
  78. int month, day, year;
  79. {
  80.     month = month - 2;
  81.  
  82.     if (month <= 0) {
  83.         month = month + 12;
  84.         year--;
  85.     }
  86.  
  87.     return (
  88.     ((day + (26 * month - 2) /10 +year +year/4 -34) % 7)+ 1
  89.     );
  90. }
  91.  
  92.  
  93.